<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

    <script>

      //创建核心对象
      var xhttp;
      if (window.XMLHttpRequest) {
        xhttp = new XMLHttpRequest();
          // 用于现代浏览器的代码
      } else {
        // code for IE6, IE5
        xhttp = new ActiveXObject("Microsoft.XMLHTTP");
          // 应对老版本 IE 浏览器的代码
      }

      //发送请求
      xhttp.open("GET", "http://localhost/ajax1");
      xhttp.send();

      //获取响应
      xhttp.onreadystatechange = function() {
          if (this.readyState == 4 && this.status == 200) {
                  alert(this.responseText);
          }
      };

    </script>

</body>
</html>